package com.xuan.judge.domain;


import com.xuan.common.core.enums.CodeRunStatus;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

@Setter
@Getter
public class SandBoxExecResult {

    private CodeRunStatus codeRunStatus;        //

    private String execMessage;     // 执行异常信息

    private List<String> execOutputList;    // 执行结果

    private Long useTime;   // 运行占用时间:ms

    private Long useMemory; // 运行占用内存:kb


    public static SandBoxExecResult success(List<String> execOutputList, Long useTime, Long useMemory) {
        SandBoxExecResult sandBoxExecResult = new SandBoxExecResult();
        sandBoxExecResult.setCodeRunStatus(CodeRunStatus.SUCCESS);
        sandBoxExecResult.setExecOutputList(execOutputList);
        sandBoxExecResult.setUseMemory(useMemory);
        sandBoxExecResult.setUseTime(useTime);
        return sandBoxExecResult;
    }

    public static SandBoxExecResult fail(CodeRunStatus codeRunStatus) {
        SandBoxExecResult sandBoxExecResult = new SandBoxExecResult();
        sandBoxExecResult.setCodeRunStatus(codeRunStatus);
        sandBoxExecResult.setExecMessage(codeRunStatus.getMsg());
        return sandBoxExecResult;
    }

    public static SandBoxExecResult fail(CodeRunStatus codeRunStatus, String execMessage) {
        SandBoxExecResult sandBoxExecResult = new SandBoxExecResult();
        sandBoxExecResult.setCodeRunStatus(codeRunStatus);
        sandBoxExecResult.setExecMessage(execMessage);
        return sandBoxExecResult;
    }

    public static SandBoxExecResult fail(CodeRunStatus codeRunStatus, List<String> execOutputList, Long useTime, Long useMemory) {
        SandBoxExecResult sandBoxExecResult = new SandBoxExecResult();
        sandBoxExecResult.setCodeRunStatus(codeRunStatus);
        sandBoxExecResult.setExecOutputList(execOutputList);
        sandBoxExecResult.setUseMemory(useMemory);
        sandBoxExecResult.setUseTime(useTime);
        return sandBoxExecResult;
    }


}
